import torch

def test_model(model, X_test, y_test, scaler):
    model.eval()
    with torch.no_grad():
        predictions = model(X_test)
        test_loss = torch.nn.MSELoss()(predictions, y_test)
        print(f'Test Loss: {test_loss.item():.4f}')

    # 反归一化
    y_test = scaler.inverse_transform(y_test.numpy())
    predictions = scaler.inverse_transform(predictions.numpy())
    return y_test, predictions
